package com.googlecode.gwtbb.client.only.remote.search;

import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.googlecode.gwtbb.client.only.GwtUtils;
import com.googlecode.gwtbb.client.only.glue.events.GwtbbEvents;
import com.googlecode.gwtbb.client.only.remote.ClientResponseEventCallback;
import com.googlecode.gwtbb.client.shared.remote.search.SearchPostsBean;
import com.googlecode.gwtbb.client.shared.remote.search.SearchPostsResponse;

/**
 * @author Abraham Grief
 * @version $Id$
 * @since Jul 29, 2008
 */
public class SearchServiceProxy implements SearchServiceAsync {
	private static final SearchServiceProxy instance = new SearchServiceProxy();
	SearchServiceAsync real = (SearchServiceAsync)GwtUtils.createProxy(GWT.create(SearchService.class), "/gwtbbExporter/searchService");

	public void searchPosts(SearchPostsBean postSearchBean, AsyncCallback async) {
		real.searchPosts(postSearchBean, new ClientResponseEventCallback<SearchPostsResponse>(async) {
			public void raiseEvent(SearchPostsResponse serverResponse) {
				GwtbbEvents.instance().fireSearchPostsEvent(serverResponse);
			}
		});
	}
}
